<template>
	<!-- 军校详情 -->
	<view>
	<view class="ranking-list">
		<uniNavBar leftImg="/static/h5img/return_black@2x.png" @clickLeft="clickLeft" :title="title"></uniNavBar>
	</view>
	<view class='school-detail'><rich-text :nodes="data"></rich-text></view>
	</view>
</template>

<script>
import api from '@/common/api';
import { ifLogin } from '@/common/js/index'
import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
	export default {
		components: {
			uniNavBar
		},
		data() {
			return {
				token: '',
				data: '',
				title: '',
			}
		},
		methods: {
			clickLeft() {
				uni.navigateBack()
			},
			async getDetail({schoolId='',newsId=''}) {
				this.token=uni.getStorageSync('token')
				if (schoolId) {
					this.title = '军校详情'
					const [err, res] = await api.schoolDetails({
						method:'get',
						header:{
							'Content-Type': 'application/json;charset=UTF-8',
							'token': this.token,
						},
						query:{
							schoolId
						}
					})
					if (res) {
						const {data:{data:{details}={},code}={}} = res
						if (code === 0) {
							this.data = details
						}
					}
				}
				if (newsId) {
					this.title = '动态详情'
					const [err, res] = await api.dynamicDetails({
						method:'get',
						header:{
							'Content-Type': 'application/json;charset=UTF-8',
							'token': this.token,
						},
						query:{
							newsId
						}
					})
					if (res) {
						const {data:{data:{details}={},code}={}} = res
						if (code === 0) {
							this.data = details
						}
					}
				}
			}
		},
		onLoad(option) {
			const status = ifLogin()
			if (status) {
				this.getDetail(option)
			}
		}
	}
</script>

<style scoped lang="scss">
	.school-detail{
		padding: 30rpx;
	}
</style>

